<?
	$filename = $_GET['path'];
	$watermark = 'images/watermark/watermark.png';
	$src = imagecreatefrompng($watermark);
	$dest = imagecreatefromjpeg($filename);
	
	list($width, $height, $type, $attr)=getimagesize($filename);
	
	// Copy and merge
	
	$tempfile=getimagesize($filename);
	
	$width=$tempfile[0];
	$height=$tempfile[1];
	
	
	$wm_W = imagesx($src); 
	$wm_H = imagesy($src); 
	
	$dest_x = $width - $wm_W; 
	$dest_y = $height - $wm_H; 
							
	
	imagecopy($dest, $src,  $dest_x, $dest_y, 0, 0, $width, $height); 

	// Output and free from memory
	header('Content-Type: image/jpeg');
	
	imagejpeg($dest);

	imagedestroy($dest);
	imagedestroy($src);

?>